package com.catchdays.main;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.catchdays.R;
import com.catchdays.db.model.CatchDaysModel;
import com.catchdays.util.StringArrayUtils;
import com.googlecode.androidannotations.annotations.EViewGroup;
import com.googlecode.androidannotations.annotations.ViewById;

@EViewGroup(R.layout.list_item)
public class CatchDaysListItemView extends LinearLayout {
	@ViewById
	protected TextView titleView;

	@ViewById
	protected TextView anniversaryTypeView;

	@ViewById
	protected TextView anniversaryDateView;

	Context context;

	public CatchDaysListItemView(Context context) {
		super(context);
		this.context = context;
	}

	public void setModel(CatchDaysModel catchDays) {
		String[] months = getResources().getStringArray(R.array.months);
		String[] days = getResources().getStringArray(R.array.days);
		String[] anniversaryTypes = getResources().getStringArray(R.array.anniversaryTypes);

		StringBuilder anniversaryDate = new StringBuilder();
		anniversaryDate.append(StringArrayUtils.get(months, catchDays.getAnniversaryMonth()));
		anniversaryDate.append(" ");
		anniversaryDate.append(StringArrayUtils.get(days, catchDays.getAnniversaryDay()));

		anniversaryDateView.setText(anniversaryDate);
		anniversaryTypeView.setText(StringArrayUtils.get(anniversaryTypes, catchDays.getAnniversaryType()));
		titleView.setText(catchDays.getTitle());
	}
}
